package core

import (
	"fmt"
	"github.com/spf13/viper"
	"go-blog/config"
)

var globalPath = "config.yaml"

func InitConfig() (c *config.Config) {
	viper.SetConfigFile(globalPath)
	viper.SetConfigType("yaml")
	if err := viper.ReadInConfig(); err != nil {
		panic(fmt.Errorf("Fatal error config file: %s \n", err))
	}
	c = new(config.Config)
	if err := viper.Unmarshal(&c); err != nil {
		panic(err.Error())
	}
	return
}
